package com.whut.controller;

import com.sun.corba.se.spi.ior.ObjectKey;
import com.whut.service.NoticeService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
@RequestMapping("/notice")
public class NoticeController {
    @Resource
    NoticeService noticeService;

    /**
     * @auther wenyihan
     * 获取所有管理员发布的通知
     * @date 18:53 2019/11/4
     * @return java.lang.Object
    */
    @ResponseBody
    @PostMapping("/getAllNotice")
    public Object getAllNotice(){return noticeService.getAllNotice();}

    /**
     * @auther wenyihan
     * 通过id查找管理员发布的通知
     * @date 18:53 2019/11/4
     * @param （id）
     * @return java.lang.Object
    */
    @ResponseBody
    @PostMapping("/getAdminById")
    public Object getAdminById(int id){return noticeService.getAdminById(id);}

    /**
     * @auther wenyihan
     * 通过时间获取某个管理员发的通知
     * @date 20:17 2019/11/4
     * @param （startTime, endTime, id）
     * @return java.lang.Object
    */
    @ResponseBody
    @PostMapping("/getNoticeByTime")
    public Object getNoticeByTime(String startTime, String endTime,int id){
        return noticeService.getNoticeByTime(startTime, endTime, id);
    }

    /**
     * @auther wenyihan
     * 添加公告
     * @date 23:10 2019/11/4
     * @param （id, notice, userName， time）
     * @return java.lang.Object
    */
    @ResponseBody
    @PostMapping("/addNotice")
    public Object addNotice(int id, String userName, String notice, String time){
        return noticeService.addNotice(id, userName, notice, time);
    }
}
